﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Masters/Basic.Master" AutoEventWireup="true" CodeBehind="Mydesk.aspx.cs" Inherits="PMS.Mydesk" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <style type="text/css">
        .list-b li {
            margin-left: 2px;
            padding-left: 18px;
            line-height: 18px;
            height: 18px;
            overflow: hidden;
            font-size: 12px;
            background: url('/Content/themes/icon/icon/arrow_right_16.png') no-repeat;
        }

        .list-b a:link {
            color: #666;
            text-decoration: none;
        }

        .list-b a:visited {
            color: #666;
            text-decoration: none;
        }

        .list-b a:hover, .list-b a:active {
            color: #ff8400;
            text-decoration: underline;
            cursor: pointer;
        }
    </style>
    <script type="text/javascript">
        var Desk = {
            rowCount: 0,
        };
        $(function () {
            Desk.AdjustWidth();
            Desk.AuditFirstLoad();
            Desk.GetWaitDealList();
            //先注释每隔30秒发送ajax
           Desk.clickWaitDealList = setInterval(Desk.GetWaitDealList, 30000);
           Desk.clickAuditList = setInterval(Desk.GetAuditList, 30000);

            $("#p1 a").each(function () {
                $(this).click(function () {
                    top.wrapper.addTab($(this).attr("alt"), $(this).attr("url"));
                });
            });
        });
    </script>


    <script type="text/javascript">
        Desk.AdjustWidth = function () {
            var auditWidth = $("#divAuditList").width();
            var waitWidth = $("#p3").width();
            var contentWidth = $("#content").width();
            var contentHeight = $("#content").height();
            var p1Width = contentWidth - auditWidth - waitWidth - 35;
            var allHeight = contentHeight - 15;
            $("#tbList").height(allHeight);
            $("#p1").panel({
                title: '快速导航菜单',
                width: p1Width,
                height: allHeight,
                closed: false,
                cache: false,

                collapsible: true, minimizable: false,
            });

            $("#p3").panel({
                title: '待办事宜',
                height: allHeight,
                closed: false,
                cache: false,

                collapsible: true, minimizable: false,
            });


        }

        Desk.AuditFirstLoad = function () {
            $.ajax({
                url: "/Logic/BD/ReviewAjax.aspx?method=GetMyReviewTask",
                type: "post",
                dataType: "json",
                success: function (data) {
                    rowCount = data.length;
                    $("#tbList").datagrid({
                        data: data,
                        loadMsg: '数据加载中请稍后……',
                        rownumbers: true,
                        idField: "ID",
                        singleSelect: false,
                        striped: true,
                        columns: [[
                         { field: 'RevNum', title: '审批单号 ', align: "center", width: 100 },
                         { field: 'DocName', title: '审批类型 ', align: "center", width: 100 },
                         { field: 'FillDate', title: '制单时间 ', align: "center", width: 140 },
                         { field: 'AddPerson', title: '制单人 ', align: "center", width: 50 },
                         { field: 'CurrentReviewName', title: '当前审核人', align: "center" }]],
                        onDblClickRow: function (rowIndex, rowData) {
                            var url = rowData.TotalUrl + "?action=review&reviewId=" + rowData.ID;
                            top.wrapper.addTab("我的审批任务", url);
                        }
                    });

                }
            });
        }


        Desk.GetWaitDealList = function () {

            $.ajax({
                url: "/Logic/BD/WaitDealAjax.aspx?method=GetPersonWaitList",
                type: "post",
                dataType: "json",
                success: function (data) {
                    $("#ulWaitDeal").html("");
                    for (var i = 0; i < data.length; i++) {
                        var wait = data[i];
                        var sign = "";
                        if (wait.count != "0") {
                            sign = "<font color='red'>(" + wait.count + ")</font>";
                        }
                        var li = "<li><a url='" + data[i].LinkUrl + "' title='" + data[i].Name + "' alt='" + data[i].PermName + "'>" + data[i].Name + sign + "</a></li>";
                        $("#ulWaitDeal").append(li);


                    }

                    $("#p3 a").each(function () {
                        $(this).click(function () {
                            top.wrapper.addTab($(this).attr("alt"), $(this).attr("url"));
                        });
                    });
                },
                error: function () {
                    $("#ulWaitDeal").html("待办事宜出错啦，请联系管理员！！！");
                }
            });
        }
        Desk.GetAuditList = function () {
            $.ajax({
                url: "/Logic/BD/ReviewAjax.aspx?method=GetMyReviewTask",
                type: "post",
                dataType: "json",
                success: function (data) {
                    if (data.length != rowCount) {
                        rowCount = data.length;
                        $("#tbList").datagrid({
                            data: data,
                            loadMsg: '数据加载中请稍后……',
                            rownumbers: true,
                            idField: "ID",
                            singleSelect: false,
                            striped: true,
                            columns: [[
                             { field: 'RevNum', title: '审批单号 ', align: "center", width: 50 },
                             { field: 'DocName', title: '审批类型 ', align: "center", width: 60 },
                             { field: 'FillDate', title: '制单时间 ', align: "center", width: 85 },
                             { field: 'AddPerson', title: '制单人 ', align: "center", width: 50 },
                             { field: 'CurrentReviewName', title: '当前审核人', align: "center" }]],
                            onDblClickRow: function (rowIndex, rowData) {
                                var url = rowData.TotalUrl + "?action=review&reviewId=" + rowData.ID;
                                top.wrapper.addTab("我的审批任务", url);
                            }
                        });
                    }
                }
            });
        }

    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div id="content" style="width: 100%; height: 100%">
        <div style="float: left;width:580px" id="divAuditList">
            <table id="tbList" title="我的待审任务 " style="width: 580px; height: 380px;">
            </table>
        </div>
        <div style="float: left; margin-left: 10px; margin-right: 5px;">
            <div id="p1" style="background: #fafafa; float: left;">
                <%for (int i = 0; i < perm.Count; i++)
                  {
                %>
                <div style="float: left; width: 60px; height: 75px; margin-left: 10px; margin-top: 5px; text-align: center">
                    <a url="<%=perm[i].LinkUrl %>" style="cursor: pointer" alt="<%=perm[i].Name %>">
                        <img src="/Images/mms/<%=perm[i].ShortCutPic %>" /><div><%=perm[i].Name %></div>
                        <div class="clear"></div>

                    </a>

                </div>

                <%
                  } %>
            </div>

        </div>
        <div style="float: right; margin-left: 5px">
            <div id="p3"
                style="width: 160px; background: #fafafa;">
                <ul id="ulWaitDeal" class="list-b" style="margin: 0; padding: 0; margin-top: 5px">
                </ul>

            </div>
        </div>
    </div>
</asp:Content>
